package com.heima.wemedia.controller.v1;

import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shiminghui
 * @date 2024/12/18 16:23
 * @description: 敏感词相关接口
 */
@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {
    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 根据id删除敏感词
     *
     * @param id
     * @return
     */
    @DeleteMapping("del/{id}")
    public ResponseResult delete(@PathVariable("id") Long id) {
        ResponseResult result = wmSensitiveService.deleteById(id);
        return result;
    }

    /**
     * 分页查询
     *
     * @param wmSensitiveDto
     * @return
     */
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmSensitiveDto wmSensitiveDto) {
        ResponseResult result = wmSensitiveService.list(wmSensitiveDto);
        return result;
    }

    /**
     * 保存敏感词
     *
     * @param wmSensitive
     * @return
     */
    @PostMapping("save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive) {
        ResponseResult result = wmSensitiveService.saveWmSensitive(wmSensitive);
        return result;
    }

    @PostMapping("update")
    public ResponseResult update(@RequestBody WmSensitive adSensitive) {
        ResponseResult result = wmSensitiveService.update(adSensitive);
        return result;
    }

}
